package com.tedu.emp.controller;

import com.tedu.common.response.JsonResult;
import com.tedu.emp.pojo.dto.EmpQuery;
import com.tedu.emp.pojo.dto.EmployeeSaveParam;
import com.tedu.emp.pojo.vo.EmpVO;
import com.tedu.emp.service.EmpService;
import com.tedu.user.pojo.dto.UserQuery;
import com.tedu.user.pojo.vo.UserVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/empl")
public class EmpController {
    @Autowired
    EmpService empService;

    @PostMapping("save")
    public JsonResult saveEmpl(EmployeeSaveParam employeeSaveParam){
        log.debug("保存员工信息:参数={}",employeeSaveParam);
        empService.saveEmployee(employeeSaveParam);
        return JsonResult.ok();
    }

    @GetMapping("select")
    public JsonResult selectUser(EmpQuery empQuery){
        log.debug("查询用户:EmpQuery={}",empQuery);
        List<EmpVO> list = empService.selectEmpl(empQuery);
        return JsonResult.ok(list);
    }



    @PostMapping("/update/password/{employeeId}")
    public JsonResult resetPassword(@PathVariable Integer employeeId){
        log.debug("重置密码，employeeId={}",employeeId);
        empService.resetPassword(employeeId);
        return JsonResult.ok();
    }

      @PostMapping("/update/status/{id}/{status}")
     public JsonResult updateStatus(@PathVariable Integer id,@PathVariable String status){
        log.debug("修改用户状态:参数={}",id,status);
        empService.updateStatus(id,status);
        return JsonResult.ok();
    }

    @PostMapping("/delete/{id}")
    public JsonResult deleteEmployee(@PathVariable Integer id){
        log.debug("删除员工信息:参数={}",id);
        empService.deleteEmployee(id);
        return JsonResult.ok();
    }


}
